package com.probiz.estore.product.dao.impl;

import java.util.List;

import com.probiz.estore.common.model.product.Product;
import com.probiz.estore.common.model.product.ProductPackageItem;
import com.probiz.estore.core.dao.impl.HibernateGenericDaoImpl;
import com.probiz.estore.product.dao.ProductPackageItemDao;

/**
 * Dao implementation for ProductPackageItem.
*/
public class ProductPackageItemDaoImpl extends HibernateGenericDaoImpl<ProductPackageItem> implements ProductPackageItemDao {

	/*
	 * (non-Javadoc)
	 * @see com.probiz.estore.product.dao.ProductPackageItemDao#getProductPackageByItemProductId(java.lang.Integer)
	 */
	public List<Product> getProductPackageByItemProductId(Integer itemProductId) {
		List<Product> productPackageList=findByHql("select distinct ppi.productSku.product from ProductPackageItem ppi where ppi.itemSku.product.productId=?", itemProductId);
		return productPackageList;
	}
	/*
	 * (non-Javadoc)
	 * @see com.probiz.estore.product.dao.ProductPackageItemDao#getActiveProductPackageByItemProductId(java.lang.Integer)
	 */
	public List<Product> getActiveProductPackageByItemProductId(Integer itemProductId){
		List<Product> productPackageList=findByHql("select distinct ppi.productSku.product from ProductPackageItem ppi where ppi.productSku.product.status = ? and ppi.itemSku.product.productId=?", Product.STATUS_ACTIVE,itemProductId);
		return productPackageList;
	}

	/*
	 * (non-Javadoc)
	 * @see com.probiz.estore.product.dao.ProductPackageItemDao#getProductPackageByItemSkuId(java.lang.Integer)
	 */
	public List<Product> getProductPackageByItemSkuId(Integer itemSkuId){
		List<Product> productList=findByHql("select distinct ppi.productSku.product from ProductPackageItem ppi where ppi.itemSku.productSkuId = ?",itemSkuId);
		return productList;
	}
}
